package com.ktjy.dao.sysUser.service.impl;

import com.ktjy.dao.sysUser.SysUserMapper;
import com.ktjy.dao.sysUser.service.SysUserService;
import com.ktjy.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Qualifier("sysUserMapper")
    @Autowired
    private SysUserMapper sysUserMapper;
    @Override
    public List<SysUser> getList(SysUser sysUser) {
        try {
            return sysUserMapper.selectSysUserList(sysUser);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public boolean add(SysUser sysUser) {
        boolean result = false;
        try {
            if(sysUserMapper.add(sysUser)==1){
                result = true;
                //测试事物回滚，打开注释
                //throw new RuntimeException
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
        return result;
    }


    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }
    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }
}
